package com.fenghongzhang.day014;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.util.Log;
import android.widget.Toast;

public class MyService2 extends Service {
    private static final String TAG = "MyService2";
    public MyService2() {
    }

    //代理人
    @Override
    public IBinder onBind(Intent intent) {
        Log.i(TAG, "onBind: ");
        //一旦用bindService来启动服务,会自动调用这个方法.
        return new MyBinder();
    }

    public class MyBinder extends Binder{
        public void callShow(){
            show();
        }
        public void callShow2(){
            show2();
        }
    }

    public void show(){
        Toast.makeText(this, "xiuer..", Toast.LENGTH_SHORT).show();
    }

    public void show2(){
        Toast.makeText(this, "2222", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onCreate() {
        super.onCreate();
        Log.i(TAG, "onCreate: ");
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Log.i(TAG, "onStartCommand: ");
        return super.onStartCommand(intent, flags, startId);
    }


    @Override
    public boolean onUnbind(Intent intent) {
        Log.i(TAG, "onUnbind: ");
        return super.onUnbind(intent);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.i(TAG, "onDestroy: ");
    }
}
